package com.simple.datax.transform.tcs;

import com.simple.datax.api.TransformerException;
import com.simple.datax.transform.util.TransformUtils;
import com.simple.datax.xml.ec.EC101ResponseDocument;
import com.simple.datax.xml.ec.EC101ResponseDocument.EC101Response;
import com.simple.datax.xml.tcs.TCS101ResponseDocument;
import com.simple.datax.xml.tcs.TCS101ResponseDocument.TCS101Response;

/**
 * @Title: Tcs2EcMessageResponseTransformer.java
 * @Package com.simple.datax.transform.tcs
 * @Description: TODO(添加描述)
 * @author Paladin Chen
 * @date 2013-1-22 下午10:15:51
 * @version V1.0
 */
public class Tcs2EcResponseTransformer extends AbstractTcs2EcTransformer {

	public EC101ResponseDocument transform(TCS101ResponseDocument src) throws TransformerException {
		TCS101Response tcsResp = src.getTCS101Response();
		com.simple.datax.xml.tcs.MessageHeadDocument.MessageHead tcsMessageHead = tcsResp.getMessageHead();

		EC101ResponseDocument ecRespDoc = EC101ResponseDocument.Factory.newInstance();
		EC101Response ecResp = ecRespDoc.addNewEC101Response();
		com.simple.datax.xml.ec.MessageHeadDocument.MessageHead ecMessageHead = ecResp.addNewMessageHead();

		messageHeadTransform(tcsMessageHead, ecMessageHead);

		TCS101Response.MessageBody tcsRespBody = tcsResp.getMessageBody();
		com.simple.datax.xml.tcs.ResponseDataDocument.ResponseData tcsRespData = tcsRespBody.getResponseData();

		EC101Response.MessageBody ecRespBody = ecResp.addNewMessageBody();
		com.simple.datax.xml.ec.ResponseDataDocument.ResponseData ecRespData = ecRespBody.addNewResponseData();
		
		ecRespData.setResponseCode(tcsRespData.getResponseCode());
		ecRespData.setResponseValue(TransformUtils.changeNullToBlank(tcsRespData.getResponseValue()));
		ecRespData.setResponseTime(TransformUtils.changeNullToBlank(tcsRespData.getResponseTime()));

		return ecRespDoc;
	}
}
